<script src="__PUBLIC_JS__/jquery.2.1.4.min.js?v={:config('hisiphp.version')}"></script>
<script src="__PUBLIC_JS__/xm-select/dist/xm-select.js?v={:config('hisiphp.version')}"></script>
<script src="__PUBLIC_JS__/vue@3.2.26/dist/vue.global.js"></script>
<style>
    /*订单显示*/
    .item{ width:270px; height:135px; border:1px solid #ccc; padding:5px;border-radius:5px;float:left;margin:5px;}
    .item .tags{width:20px;float:left;text-align:center;}
    .item .pic{width:100px; float:left;text-align:center;}
    .item .pic img{max-width:100px; max-height:135px;border-radius:5px;}
    .item .text{width: 150px;text-align:left;float: right;}
    .text-item{width: 100%;}
    .clear{clear:both;}
    .layui-btn-small {
        height: 20px;
        line-height: 20px;
        padding: 0 5px;
        font-size: 12px;
    }
    .small-table{margin: 0; }
    .small-table td{padding: 4px;font-size: 10px}
</style>
<div class="fixed-bar">
    <form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search" >
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">订单号</label>
                <div class="layui-input-inline">
                    <input type="text" name="client_ordernum" value="" lay-verify="" placeholder="输入订单号" class="layui-input">
                </div>
            </div>
            <div class="layui-inline removeStat">
                <label class="layui-form-label">SKU</label>
                <div class="layui-input-inline">
                    <input type="text" name="sku" value="" lay-verify="" placeholder="输入SKU" class="layui-input">
                </div>
            </div>
            <div class="layui-inline removeStat">
                <label class="layui-form-label">下单日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="create_date_range" readonly="" id="create_date_range" lay-verify="" placeholder="选择下单日期" class="layui-input">
                </div>
            </div>
            <div class="layui-inline removeStat">
                <label class="layui-form-label">核价类型</label>
                <div class="layui-input-inline">
                    {:Form::select('type', '', $typeMapSelect_10000, '', '')}
                </div>
            </div>
            <div class="layui-inline removeStat">
                <label class="layui-form-label">所属工厂</label>
                <div class="layui-input-inline">
                    {:Form::select('factory_id', '', $factoryKV, '', '')}
                </div>
            </div>
            <div class=" layui-inline layui-upload">
                <button type="submit" class="layui-btn"  lay-submit="" lay-filter="demo1"  >搜索</button>
            </div>
        </div>
    </form>
</div>
{include file="mp@cost_check/statistics_detail_coverLoss" /}
{include file="mp@cost_check/menu_cover_loss" /}

<table id="dataTable" lay-filter='dataTable'></table>

{include file="system@block/layui" /}
<script type="text/html" id="picTpl">
    <span class="lay-pic-container" src="{{ d.pic }}">
		<img src="{{ d.ori_pic }}" class="lay-pic">
	</span>
</script>
<script type="text/html" id="skuTpl">
    <span class="copy-item">{{ d.client_ordernum }}</span> <br>
    <span class="copy-item">{{ d.sku }}</span> <br>
    {{ d.factory_name }}
</script>
<script type="text/html" id="nameTpl">
    {{layui.tool.formatMaterialType(d.material_type,'',2)}}<span class='copy-item'>{{d.material_name}}</span>
</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group lr">
        {if ($status==0) }
        <a href="{:url('add10000')}" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-add-circle-fine hisi-iframe" hisi-data="{width: '50%', height: '50%'}" title="新建核价订单">&nbsp;新建补损</a>
        <a data-href="{:url('check')}?type_name=hejia&status=50" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon">发起补损</a>
		<a data-href="{:url('check')}?type_name=hejia&status=150" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon">无需补损</a>
        {/if}
        {if ($status==50) }
        <a data-href="{:url('check')}?type_name=hejia&status=100" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon">补损完成</a>
        {/if}
    </div>
</script>
<script type="text/javascript">
    var res_data={};//所有数据集
    var txt_data={};
    layui.use([ 'element', 'layer', 'laytpl', 'tool','laydate','table','form','flow'], function() {
        var element = layui.element;
        var layer = layui.layer;
        var $ = layui.jquery;
        var form = layui.form;
        var laytpl = layui.laytpl,laydate=layui.laydate ,table = layui.table;
        var flow = layui.flow;

        laydate.render({
            elem: '#create_date_range'
            ,range: '~'
            ,theme: 'molv'
            // ,mark: {'':''}
            ,change: function(value, date, endDate){
                $('#create_date_range').val(value);
                $('#layui-laydate1').remove();//关闭面板
            }
        });

        table.render({
            elem: '#dataTable'
            ,url: '{:url("", [])}' //数据接口
            ,page: true //开启分页
            //,skin: 'row'
            ,even: true
            ,limit: 20
            ,limits: [5,20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            // ,width:document.documentElement.clientWidth-50
            ,defaultToolbar: ['exports', 'print']
            ,cols: [[ //表头
                {type:'checkbox'}
                ,{field:'pic',title : '图片', templet:'#picTpl',width:110}
                ,{field: 'col2', title: '订单号/sku/工厂',width:160,templet:'#skuTpl'}

                ,{field: 'material_name', title: '材料名称',width:160,templet:'#nameTpl'}
                ,{field: 'color', title: '颜色',width:55}
                ,{field: 'stalls_name', title: '档口',width:80}
                ,{field: 'customer_price', title: '原价',width:55}
                ,{field: 'type_txt', title: '补损类型',width:80}
                ,{field: 'true_num_txt', title: '实际与客户信息',width:120}
                ,{field: 'cover_loss_txt', title: '需补损',width:70}
                ,{field: 'status_txt', title: '订单状态',width:100}
                ,{field: 'return_num', title: '核价次数'}
                ,{field: 'create_time', title: '下单日期'}
				,{field: 'check_create_time', title: '创建日期',width:140}
                ,{field: 'remark', title: '备注',width:90,edit:'text',style:'border-bottom:2px dotted #5FB878;'}
                // ,{field: 'col3', title: today'操作',templet:'#buttonTpl'}
            ]]
            ,done: function(res, curr, count){
                var data=res.data;
                var status=res.status;
                stat_set();
                table.on('edit(dataTable)', function(obj){
                    var value = obj.value //得到修改后的值
                        ,d = obj.data //得到所在行所有键值
                        ,field = obj.field; //得到字段
                    var id=d.id;

                    $.ajax({
                        type: "POST",
                        url: "{:url('editUnit')}",
                        data: "id="+d.id+"&field="+field+"&value="+value,
                        dataType:"json",
                        success: function(res){
                            if (res.code == 1) {
                                layer.msg(res.msg, {icon: 1});
                            } else {
                                layer.msg(res.msg, {icon: 2,anim: 6});
                            }
                        }
                    });
                });
            }
        });
    });

</script>